package com.team.arms.tijian.controller;


import com.team.arms.common.ry.core.domain.AjaxResult;
import com.team.arms.political.service.PoliReviewInfoService;
import com.team.arms.tijian.entity.vo.AllVO;
import com.team.arms.tijian.entity.vo.HealthPassVo;
import com.team.arms.tijian.mapper.SysHealthExaminationMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 体检详情表 前端控制器
 * </p>
 *
 * @author Huazige
 * @since 2022-06-02
 */
@RestController
@RequestMapping("/HealthExamination")
@Api(tags="体检合格模块")
@CrossOrigin
public class SysHealthExaminationController {

    @Autowired
    PoliReviewInfoService poliReviewInfoService;

    @Resource
    SysHealthExaminationMapper sysHealthExaminationMapper;

    @ApiOperation("获取体检合格信息")
//    @Log(title = "政审信息", businessType = BusinessType.)
    @GetMapping(value = "/get")
    public AjaxResult selectpltc() {

        List<HealthPassVo> list = sysHealthExaminationMapper.selectall();
//

        if (list!=null){
            return AjaxResult.success("查询成功",list) ;
        }
        else {
            return AjaxResult.error("查询失败");
        }


    }
    @ApiOperation(value = "体检合格-下拉框查找")
    @GetMapping("/find")
    public AjaxResult getrecommendbyname(@RequestParam(value = "查询的字段") String field , @RequestParam(value = "查询的内容")String content) {
        //也可以直接从redis缓冲中去调用一个foreach循环拿到对应name的数据

        List<HealthPassVo> list = sysHealthExaminationMapper.selectallbyname(field,content);

        if (list.size()>0){
            return AjaxResult.success("查找成功",list);
        }else {
            return    AjaxResult.success("没有找到信息");
        }

    }
    @ApiOperation("导出所有体检合格的信息")
    @GetMapping("/export")
    public void exportfailed(HttpServletResponse response) {

        List<HealthPassVo> list = sysHealthExaminationMapper.selectall();
//
        poliReviewInfoService.exportpoli(response, list, HealthPassVo.class,"体检合格表");

    }
    @ApiOperation("获取某个人的详情内容")
    @GetMapping(value = "/getall/{examineId}}")
    public AjaxResult selectall(
            @PathVariable("examineId")String examineId
    ) {

        List<AllVO> list = sysHealthExaminationMapper.select(examineId);
        return AjaxResult.success("查询成功",list) ;

    }
}

